<template>
    <div class="app-mine__list">
        <div class="app-mine__list-item">
            <!-- 优惠券单元格 -->
            <van-cell title="会员中心" is-link  :to="isLoggined?'list':'main'" />
            <van-coupon-cell
            :coupons="coupons"
            :chosen-coupon="chosenCoupon"
            @click="showList = true"
            />
            <!-- 优惠券列表 -->
            <van-popup
            v-model:show="showList"
            round
            position="bottom"
            style="height: 90%; padding-top: 4px;"
            >
            <van-coupon-list
                :coupons="coupons"
                :chosen-coupon="chosenCoupon"
                :disabled-coupons="disabledCoupons"
                @change="onChange"
                @exchange="onExchange"
            />
            </van-popup>

            <van-cell-group>
                <van-cell title="服务中心" is-link  to="main" />
                <van-cell title="小米之家" is-link  to="main" />
                <van-cell title="我的F码" is-link  to="fcode" />
                <van-cell title="礼物码兑换" is-link  to="fcode" />
                <van-cell title="设置" is-link to="adress" />
            </van-cell-group>

          <!-- <van-cell title="会员中心" is-link  :to="isLoggined?'list':'main'" />
            <van-coupon-cell
            :coupons="coupons"
            :chosen-coupon="chosenCoupon"
            @click="showList = true" /> -->
            <!-- 优惠券列表 -->
              <!-- <van-popup
                v-model:show="showList" 
                round position="bottom" 
                style="height: 90%; 
                padding-top: 4px;">
            <van-coupon-list 
            :coupons="coupons"
            :chosen-coupon="chosenCoupon" 
            :disabled-coupons="disabledCoupons"
            @change="onChange" 
            @exchange="onExchange" />
            </van-popup>
            <van-cell-group>
                <van-cell title="服务中心" is-link  to="main" />
                <van-cell title="小米之家" is-link  to="main" />
                <van-cell title="我的F码" is-link  to="fcode" />
                <van-cell title="礼物码兑换" is-link  to="fcode" />
                <van-cell title="设置" is-link to="adress" />
            </van-cell-group> -->

        <!-- <div class="app-mine__list-item">
        <van-cell title="服务中心" is-link  to="main" />
        <van-cell title="小米之家" is-link  to="main" />
        </div>
        <div class="app-mine__list-item">
            <van-cell title="我的F码" is-link  to="fcode" />
            <van-cell title="礼物码兑换" is-link  to="fcode" />
        </div>
        <div>
            <van-cell title="设置" is-link to="adress" />
        </div> -->
        </div>
    </div>
</template>
<script setup lang="ts">
import useAuthorityStore from '@/stores/authority'
import { storeToRefs } from 'pinia'
import { ref } from 'vue'
import type { CouponCellProps, CouponInfo, CouponListProps } from 'vant';
const authStore = useAuthorityStore()
const { isLoggined } = storeToRefs(authStore)
const coupon=ref<CouponInfo[]>({
      id:1,
      condition: '无门槛\n最多优惠12元',
      reason: '',
      value: 150,
      name: '优惠券名称',
      startAt: 1489104000,
      endAt: 1514592000,
      valueDesc: '1.5',
      unitDesc: '元',
      description:'哈哈哈'
})

    const coupons = ref([coupon]);
    const showList = ref(false);
    const chosenCoupon = ref(-1);

    const code = ref<number>(1234555)
    const onChange = (index:number) => {
      showList.value = false
      chosenCoupon.value = index;
    };
    const onExchange = (code:string): void => {
      coupons.value.push(coupon);
    };
    const disabledCoup={
        disabledCoupons:coupons.value
    }
</script>
<style lang="scss">
.app-mine__list{
    background-color: rgb(245, 245, 245);
    .app-mine__list-item{
        margin-bottom: 12px;
    }
}
</style>